package enemy;

import bullets.BulletEnemy;
import core.FlyingObject;

/**
 * 所有敌人的父类，但是本身也继承飞行物这个父类
 * @author soft01
 *
 */
public abstract class Enemy extends FlyingObject{
	/**
	 * 
	 */
	private static final long serialVersionUID = 3644514936646963344L;
	/*
	 * 继承Enemy，又有width,high,x,y属性
	 * 自身拥有speed和life属性
	 * 这个speed属性只代表纵向，其他子类如果有横向移动，
	 * 会有另外一个speed来表示
	 * 每碰撞一次，life减少一点,life为0时，调用父类的setState改为DEAD。
	 */
	protected int speed;
	protected int life;
	private boolean mark;//标记，true表示会在子弹跟踪，false不会被跟踪

	public Enemy() {
		super();
	}
	public Enemy(int width, int high) {
		super(width, high);
	}
	public Enemy(int width, int high,int speed,int life) {
		super(width, high);
		this.speed = speed;
		this.life = life;
		mark = false;
	}
	public Enemy(int width, int high,int x,int y,int speed,int life) {
		super(x,y,width, high);
		this.speed = speed;
		this.life = life;
		mark = false;
	}
	//重写
	public void goDead() {//去死	
		life--;
		if(life<=0) {			
			status=dead;	
		}
	}
	public int getLife() {
		return life;
	}
	public boolean isMark() {
		return mark;
	}

	public void setMark(boolean mark) {
		this.mark = mark;
	}	
	public void step2(int x,int y) {//大招出现时的移动方式
		if(x<this.x) {
			this.x-=speed;
		}else {
			this.x+=speed;
		}
		if(y<this.y) {
			this.y-=speed;
		}else {
			this.y+=speed;
		}
	}
	/*
	 * 每个子类重写特有的射击方式
	 */
	public abstract BulletEnemy enemyShoot();
	public abstract void step();
	
}
